package com.chat.view;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.View;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

public class SetView implements View {

    @Override
    public String getContentType() {
        return null;
    }

    @Override
    public void render(Map<String, ?> map, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException{
        httpServletResponse.setHeader("Content-type", "text/html;charset=UTF-8");
        //2.让servlet用UTF-8转码
        httpServletResponse.setCharacterEncoding("UTF-8");

        httpServletResponse.getWriter().print("hello view: 自定义视图解析器测试");
    }
}
